<?php

namespace app\common\service\goods\source;

use app\api\model\DiscountGoods;
use think\facade\Db;

class Discount extends Basics
{

    function updateGoodsStock($goodsList)
    {
        // TODO: Implement updateGoodsStock() method.
        // 更新活动商品库存

    }

    function updateStockSales($goodsList)
    {
        // TODO: Implement updateStockSales() method.
    }

    function backGoodsStock($goodsList, bool $isPayOrder = false)
    {
        foreach ($goodsList as $item) {
            DiscountGoods::update([
                'stock' => Db::raw('stock+' . $item['total_num']),
                'sale'  => Db::raw('sale-' . $item['total_num'])
            ], ['id' => $item['goods_source_id']]);
        }
    }

    function goodsStatus($goodsList)
    {
        // TODO: Implement goodsStatus() method.
    }
}